﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Collections.ObjectModel;
using System.Windows.Input;
using QLab.Utility;

namespace QLab.Model
{
	/// <summary>
	/// Wrapper for data that will be displayed in solution explorer
	/// </summary>
	public class ProjectItem : Notifier
	{
		private string _text;
		private ObservableCollection<ProjectItem> _children = new ObservableCollection<ProjectItem>();
		private object _dataReference;
		private bool _expanded;
		private bool _editable;
		private bool _isInEditMode = false;
		private bool _isSelected = false;
		private ICommand _command;

		/// <summary>
		/// Text to display in solution explorer
		/// </summary>
		public string Text
		{
			get { return _text; }
			set { _text = value; OnPropertyChanged("Text"); }
		}

		/// <summary>
		/// Children of this navigation item
		/// </summary>
		public ObservableCollection<ProjectItem> Children
		{
			get { return _children; }
			set	{ _children = value; OnPropertyChanged("Children");	}
		}

		/// <summary>
		/// Reference to the object that instance of this class wraps
		/// </summary>
		public object DataReference
		{
			get { return _dataReference; }
			set { _dataReference = value; OnPropertyChanged("DataReference"); }
		}

		/// <summary>
		/// Is it expanded in solution explorer
		/// </summary>
		public bool Expanded
		{
			get { return _expanded; }
			set { _expanded = value; OnPropertyChanged("Expanded"); }
		}

		/// <summary>
		/// Is this item editable
		/// </summary>
		public bool Editable
		{
			get { return _editable; }
			set { _editable = value; OnPropertyChanged("Editable"); }
		}

		/// <summary>
		/// Are we editing current item
		/// </summary>
		public bool IsInEditMode
		{
			get { return _isInEditMode; }
			set
			{
				if (_editable == false)
					return;
				_isInEditMode = value;
				OnPropertyChanged("IsInEditMode");
			}
		}

		/// <summary>
		/// Is this item selected in list
		/// </summary>
		public bool IsSelected
		{
			get { return _isSelected; }
			set { _isSelected = value; OnPropertyChanged("IsSelected"); }
		}

		/// <summary>
		/// Command that is related to this item
		/// </summary>
		public ICommand Command
		{
			get { return _command; }
			set { _command = value; OnPropertyChanged("Command"); }
		}
	}
}
